#define _CRT_SECURE_NO_WARNINGS 1 

#include <iostream>
#include <vector>
using namespace std;

class Solution
{
public:
    vector<int> missingTwo(vector<int>& nums)
    {
        int temp = 0;
        int n = nums.size();
        for (auto x : nums)
        {
            temp ^= x;
        }
        for (int i = 1; i <= n + 2; i++)
        {
            temp ^= i;
        }
        int diff = 0;
        for (int i = 0; i < 32; i++)
        {
            if (((temp >> i) & 1) == 1)
            {
                diff = i;
                break;
            }
        }
        int a = 0, b = 0;
        for (auto x : nums)
        {
            if (((x >> diff) & 1) == 1) a ^= x;
            else b ^= x;
        }
        for (int i = 1; i <= n + 2; i++)
        {
            if (((i >> diff) & 1) == 1) a ^= i;
            else b ^= i;
        }
        return { a, b };
    }
};

int main()
{
    Solution sol;
    vector<int> nums, ret;
    nums.push_back(1);
    nums.push_back(2);
    nums.push_back(9);
    nums.push_back(12);
    nums.push_back(6);
    nums.push_back(5);
    nums.push_back(7);
    nums.push_back(3);

    ret = sol.missingTwo(nums);

    for (auto e : ret)
    {
        cout << e << " ";
    }
    return 0;
}